import { defineStore} from 'pinia';
import * as storage from '@/utils/storage'
import constant from '@/utils/constant';
import { ref, computed } from 'vue' 


export const useReadStore = defineStore('read',() => {
    const fontSize = ref<number>(storage.get(constant.fontSize))
    const lineHeight = ref<any>(storage.get(constant.lineHeight))

    const bgColor = ref<any>(storage.get(constant.bgColor))

    const getFontSize =  computed(() => fontSize.value)

    const getLineHeight = computed(() => lineHeight.value)

    const getBgColor = computed(() => bgColor.value)

    function SetBgColor (backgroudColor: any) :void {
        storage.set(constant.bgColor,backgroudColor)
        bgColor.value = backgroudColor
    }

    function SetLineHeight (height: any) :void {
        storage.set(constant.lineHeight,height)
        lineHeight.value = height
    }

    function SetFontSize(size : number) :void {
        storage.set(constant.fontSize,size)
        fontSize.value = size
    }
    return {SetFontSize,getFontSize,getLineHeight,SetLineHeight, getBgColor,SetBgColor}
})